#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include "qtstreambuf.h"
#include "workerThread.h"
#include "q_debugstream.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class Widget;
}
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

    // QMessage
    /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    static  void QMessageOutput(QtMsgType , const QMessageLogContext &, const QString &msg);
    /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/

private slots:
    void on_btn_SelectDbcfile_clicked();

    void on_btn_analyse_clicked();

    void on_btn_SelectOutCodeFilePath_clicked();

    void dealsigResult(QString, unsigned int);

public:
    QString textbuf;
    std::shared_ptr<qtStreamBuf> buffer;
    void Append(const QString &text);

public:
    void workThreadInit();
private:
    Ui::Widget *ui;

    // MessageHandler for display and ThreadLogStream for redirecting cout
    /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
    MessageHandler *msgHandler = Q_NULLPTR;
    ThreadLogStream* m_qd;
    /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
};
#endif // WIDGET_H
